<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title data-i18n="resources.title_tiledMapLayer_rasterfunction"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
    <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
  </head>
  <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
    <div id="map" style="width: 100%;height:100%"></div>
    <script type="text/javascript">
      var map,
        url = 'https://iserver.supermap.io/iserver/services/map-ndvi/rest/maps/hainanImage';
      map = new ol.Map({
        target: 'map',
        // ol v7版本用法为ol.control.defaults.defaults； v6版本以下用法为ol.control.defaults
        controls: ol.control.defaults.defaults({ attributionOptions: { collapsed: false } })
          .extend([new ol.supermap.control.Logo({ link: "https://iclient.supermap.io" })]),
        view: new ol.View({
          center: [12189483.19 , 2155290.02],
          zoom: 12,
          maxZoom: 12,
          projection: 'EPSG:3857',
          multiWorld: true
        })
      });
      var layer = new ol.layer.Tile({
        source: new ol.source.TileSuperMapRest({
          url: url,
          rasterfunction: new ol.supermap.NDVIParameter({ redIndex: 0, nirIndex: 2 }),
          cacheEnabled: false,
          format:'jpg'
        }),
        projection: 'EPSG:3857'
      });
      map.addLayer(layer);
      map.addControl(new ol.supermap.control.ScaleLine());
    </script>
  </body>
</html>
